//    Copyright (C) Kherty.  All rights reserved.
using System;
using OpenLS.Core.Serialization;
using OpenLS.Drawing;

namespace OpenLS.Chart
{
    public class DataTable : IOfficeXmlSerializable
    {
        private bool? _showHorzBorder;
        private bool? _showVertBorder;
        private bool? _showOutline;
        private bool? _showKeys;
        private ShapeProperties _spPr;
        private TextBody _txPr;
        private ExtensionList _extLst;

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read("dTable"))
            {
                _showHorzBorder = c.ReadOptionalElementBooleanAttribute("showHorzBorder");
                _showVertBorder = c.ReadOptionalElementBooleanAttribute("showVertBorder");
                _showOutline = c.ReadOptionalElementBooleanAttribute("showOutline");
                _showKeys = c.ReadOptionalElementBooleanAttribute("showKeys");
                _spPr = c.ReadOptionalElement<ShapeProperties>("spPr");
                _txPr = c.ReadOptionalElementAs<TextBody>("txPr");
                _extLst = c.ReadOptionalElement<ExtensionList>("extLst");
            }
        }

        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write("dTable"))
            {
                c.WriteOptionalElementBooleanAttribute("showHorzBorder", _showHorzBorder);
                c.WriteOptionalElementBooleanAttribute("showVertBorder", _showVertBorder);
                c.WriteOptionalElementBooleanAttribute("showOutline", _showOutline);
                c.WriteOptionalElementBooleanAttribute("showKeys", _showKeys);
                c.WriteOptionalElement( _spPr);
                c.WriteOptionalElementAs(_txPr, "txPr");
                c.WriteOptionalElement(_extLst);
            }
        }
    }
}